﻿//#define RUNSERVICE
#define Command
using Fujitsu.JiraAnalysis.DAL;

namespace Fujitsu.JiraAnalysis.ReplicationService
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
#if RUNSERVICE
            var ServicesToRun = new System.ServiceProcess.ServiceBase[] 
                                              { 
                                                  new ReplicationService() 
                                              };
            System.ServiceProcess.ServiceBase.Run(ServicesToRun);
#else
#if Command
            var projectStorage = new ProjectStorage();
            var syncDispatcher = new CommandDispatcher();
            
            var projects = projectStorage.GetProjectsToSynchronize();

            foreach (var project in projects)
            {
                var command = new SyncCommand(project);
                syncDispatcher.ExecuteCommand(command);
            }
#else
            var projectSync = new Synchronize.ProjectSync();
            var adapterCreator = new TrackingSystemAdapter.AdapterCreator();
            projectSync.StartReplication(adapterCreator);
#endif
#endif
        }
    }
}
